package com.hdl.servlet.mallproduct;

import java.io.IOException;
import java.util.List;

import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hdl.entity.MallProduct;
import com.hdl.service.MallProductService;
import com.hdl.service.impl.MallProductServiceImpl;

@WebServlet("/mallproduct.let")
public class MallProductServlet extends HttpServlet{
	private MallProductService mp = new MallProductServiceImpl();
     @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	 request.setCharacterEncoding("utf-8");
    	 
    	 //获取typeid
    	 int typeid=1;
    	 try {
    		 typeid = Integer.valueOf(request.getParameter("typeid"));
		} catch (Exception e) {
		}
    	
    	//获得商品列表
    	List<MallProduct> list = mp.SelectAllProductByTypeId(typeid);
    	
    	request.setAttribute("mallproductlist", list);
    	request.setAttribute("tpid", typeid);
    	
    	request.getRequestDispatcher("/meishi.jsp").forward(request, response);
    	
    	
    
     }
     
     @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	doGet(req, resp);
    }
}
